import { createRouter, createWebHistory } from 'vue-router'
import LoginView from '../views/LoginView.vue'
import RegisterView from '@/views/RegisterView'
import HomeView from '@/views/HomeView'
import NotFound from '@/views/NotFound'
import MyBlog from '@/views/MyBlog'
import AboutView from '@/views/AboutView'
import OnlineJudge from '@/views/OnlineJudge'
import GameView from '@/views/GameView'
import WriteArtilce from '@/views/WriteArtilce'
import AceEditor from '@/views/AceEditor'

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: "/index",
  },
  {
    path: '/edit',
    name: 'edit',
    component: AceEditor
  },
  {
    path: '/index',
    name: 'index',
    component: HomeView
  },
  {
    path: '/game',
    name: 'game',
    component: GameView
  },
  {
    path: '/write',
    name: 'write',
    component: WriteArtilce
  },
  {
    path: '/online',
    name: 'online',
    component: OnlineJudge
  },
  {
    path: '/myblog',
    name: 'myblog',
    component: MyBlog
  },
  {
    path: '/about',
    name: 'about',
    component: AboutView
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView
  },
  {
    path: '/register',
    name: 'register',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: RegisterView
  },
  {
    path: '/404',
    name: '404',
    component: NotFound,
  },
  {
    path: '/:catchAll(.*)',
    redirect: "/404"
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
